home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
examples
/
chap03
/
MoveIt.java
< prev
next >
Wrap
Text File
|
1996-10-18
|
708b
|
31 lines
import vrml.*;
import vrml.field.*;
import vrml.node.*;
public class MoveIt extends Script {
private SFBool on; // status of on-off
float red[] = { 1, 0, 0 }; // RGB(Red)
float blue[] = { 0, 0, 1 }; // RGB(Blue)
private SFNode theNode ;
private SFVec3f position;
public void initialize() {
theNode = (SFNode) getField("node");
}
public void processEvent(Event e) {
ConstSFBool v = (ConstSFBool)e.getValue();
Node node;
if(v.getValue()){
node = (Node)(theNode.getValue());
position = (SFVec3f)(node.getExposedField("translation"));
position.setValue((position.getX() + 5), 0, 0);
}
}
}